<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 * 手机白名单
 */
class WhitePhone extends Model
{
    protected $table = 'white_phone';

    protected $fillable = [
        'user_id', 'phone', 'flag'
    ];

    /**
     * 获取N条语音文案
     */
    static function getPhones()
    {
        $list = self::where(['flag' => 1])->pluck('phone')->toArray();
        return array_unique($list);
    }

    static function addPhone($userId = 0, $phone = '')
    {
        return self::create([
            'user_id' => $userId,
            'phone' => $phone,
            'flag' => 1
        ]);
    }
}
